﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Dora.Services.AdminUser.Dto.QueryDto;
using Dora.Services.AdminUser.Dto.SaveDto;
using Dora.Services.AdminUser.Dto.ViewDto;
using Dora.Services.AdminUser.Entities;
using Dora.Services.Product.Dto.QueryDto;
using Dora.Services.Supplier.Dto.ViewDto;
using Dora.Tools.Enums.AdminUser;
using Dora.Tools.Utility.Const;
using Dora.Tools.Utility.Models;
using Surging.Core.Common;
using Surging.Core.CPlatform.Ioc;
using Surging.Core.CPlatform.Runtime.Server.Implementation.ServiceDiscovery.Attributes;

namespace Dora.Services.AdminUser.IApplication
{
    [ServiceBundle("api/" + DoraModuleName.AdminUser + "/{Service}")]
    public interface IOrganizationService : IServiceKey
    {
        /// <summary>
        /// 保存组织机构信息
        /// </summary>
        /// <param name="organization"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "保存组织机构信息")]
        Task<int> SaveOrganizationInfo(OrganizationEditDto organization);

        /// <summary>
        /// 删除组织机构信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "删除组织机构信息")]
        Task<bool> DeleteOrganization(int orgId);

        /// <summary>
        /// 根据主键查询组织机构信息（编辑）
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "根据主键查询组织机构信息")]
        Task<OrganizationEditDto> GetOrganizationInfoById(int orgId);

        /// <summary>
        /// 查询指定LevelPath中的Id所对应的机构列表
        /// </summary>
        /// <param name="orgLevelPath"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "查询指定LevelPath中的Id所对应的机构列表")]
        Task<List<OrganizationDto>> GetOrgLevelInfoList(string orgLevelPath);

        /// <summary>
        /// 根据主键查询组织机构信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-20", Director = "李龙", Name = "根据主键查询组织机构信息")]
        Task<OrganizationDto> GetOrgInfoById(int orgId);

        /// <summary>
        /// 根据主键查询组织机构信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-20", Director = "李龙", Name = "根据主键查询组织机构信息")]
        Task<OrganizationEntity> GetById(int id);

        /// <summary>
        /// 查询指定机构Id及下属机构集合
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "查询指定机构Id及下属机构集合")]
        Task<List<OrganizationEntity>> GetSubOrganizations(int orgId);

        /// <summary>
        /// 分页获取数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "分页获取数据")]
        Task<PageDataList<OrganizationEntity>> GetPageList(OrganizationQueryDto input);

        /// <summary>
        /// 分页获取数据（带组织机构层级）
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-04-30", Director = "李龙", Name = "分页获取数据（带组织机构层级）")]
        Task<PageDataList<OrganizationDto>> GetOrganizationPageList(OrganizationQueryDto input);

        /// <summary>
        /// 查询组织机构树
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-10", Director = "李龙", Name = "查询组织机构树（带组织机构层级）")]
        Task<List<OrganizationDto>> GetOrganizationTreeList(OrganizationQueryDto query);

        /// <summary>
        /// 查询总社机构列表信息
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-05-13", Director = "李龙", Name = "查询总社机构列表信息")]
        Task<List<OrganizationDto>> GetMasterOrgList();

        /// <summary>
        /// 查询具有独立保险签约资质的分社列表
        /// </summary>
        /// <returns></returns>
        [Service(Date = "2019-05-27", Director = "李龙", Name = "查询具有独立保险签约资质的分社列表")]
        Task<List<OrganizationDto>> GetSubInsuranceOrgs(int orgId);

        /// <summary>
        /// 设置组织机构冻结/解冻状态
        /// </summary>
        /// <param name="stateSetDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-14", Director = "李龙", Name = "设置组织机构冻结/解冻状态")]
        Task<bool> SetOrgFreeze(OrgStateSetDto stateSetDto);

        /// <summary>
        /// 设置组织机构禁用/启用状态
        /// </summary>
        /// <param name="stateSetDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-14", Director = "李龙", Name = "设置组织机构禁用/启用状态")]
        Task<bool> SetOrgDisabled(OrgStateSetDto stateSetDto);

        /// <summary>
        /// 查询指定Id的组织机构的下一级机构列表
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-16", Director = "李龙", Name = "查询指定Id的组织机构的下一级机构列表")]
        Task<List<OrganizationDto>> GetSubOrgList(int orgId);

        /// <summary>
        /// 查询指定Id的组织机构的门店列表
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-18", Director = "李龙", Name = "查询指定Id的组织机构的门店列表")]
        Task<List<OrganizationDto>> GetStoreOrgList(int orgId);

        /// <summary>
        /// 查询用户组织机构映射信息
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-16", Director = "李龙", Name = "查询用户组织机构映射信息")]
        Task<TasOrgUserMapEntity> GetOrgUserMapInfo(Guid userId, int orgId);

        /// <summary>
        /// 查询组织机构的类型
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-27", Director = "李龙", Name = "查询组织机构的类型")]
        Task<ResultDto<PermissionOrgType>> GetPermissionOrgType(int orgId);

        /// <summary>
        /// 查询距离位置附近的门店信息列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-25", Director = "李龙", Name = "查询距离位置附近的门店信息列表")]
        Task<PageDataList<NearestStoreOrgDto>> GetNearestStoreOrgPageList(NearestStoreQueryDto query);

        /// <summary>
        /// 根据查询条件查询组织机构列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-25", Director = "李龙", Name = "根据查询条件查询组织机构列表")]
        Task<List<OrgSimpleDto>> GetOrgList(OrganizationQueryDto query);

        /// <summary>
        /// 更改管理员
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-24", Director = "TTTan", Name = "更改管理员")]
        Task<ResultDto> ChangeAdmin(int orgId, Guid userId);

        /// <summary>
        /// 更改负责人
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-24", Director = "TTTan", Name = "更改负责人")]
        Task<ResultDto> ChangeLeader(int orgId, Guid userId);


        /// <summary>
        /// 获取分社门店分页数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-27", Director = "wyq", Name = "获取分社门店分页数据")]
        Task<PageDataList<TasOrgListItemDto>> GetOrgBranchPageList(OrganizationQueryDto input);

        /// <summary>
        /// 获取大社下分社或门店列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-27", Director = "wyq", Name = "获取分社门店分页数据")]
        Task<List<OrganizationEntity>> GetSubBranchOrgList(int orgId, int orgLevel);


        #region 设置企业/门店信息

        /// <summary>
        /// 查询大社/分社企业信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "李龙", Name = "查询大社/分社企业信息")]
        Task<TravelServiceOrgEditDto> GetTravelServiceOrgInfo(int orgId);

        /// <summary>
        /// 查询门店企业信息
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "李龙", Name = "查询门店企业信息")]
        Task<StoreInfoEditDto> GetStoreOrgInfo(int orgId);

        /// <summary>
        /// 保存大社/分社的企业信息
        /// </summary>
        /// <param name="orgInfo"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "李龙", Name = "保存大社/分社的企业信息")]
        Task<ResultDto<int>> SaveTravelServiceOrgInfo(TravelServiceOrgEditDto orgInfo);

        /// <summary>
        /// 保存门店的企业信息
        /// </summary>
        /// <param name="orgInfo"></param>
        /// <returns></returns>
        [Service(Date = "2019-05-30", Director = "李龙", Name = "保存门店的企业信息")]
        Task<ResultDto<int>> SaveStoreOrgInfo(StoreInfoEditDto orgInfo);

        #endregion

        /// <summary>
        /// 查询给定机构下匹配关键字的下级机构列表
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="keywords"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-04", Director = "李龙", Name = "查询给定机构下匹配关键字的下级机构列表")]
        Task<ResultDto<List<OrganizationDto>>> GetSubOrgListByOrgIdAndKeywords(int orgId, string keywords);

        /// <summary>
        /// 更新大社/分社签约的供应商数量
        /// </summary>
        /// <param name="orgId">组织机构ID</param>
        /// <param name="supplierCount">已签约的供应商数量</param>
        /// <returns></returns>
        [Service(Date = "2019-06-10", Director = "李龙", Name = "更新大社/分社签约的供应商数量")]
        Task<ResultDto<bool>> SetSupplierCount(int orgId, int supplierCount);

        /// <summary>
        /// 查询可用于和供应商进行签约的大社和具有独立签约供应商资质的分社的集合
        /// </summary>
        /// <param name="queryInfo">分页信息以及被排除的机构Id集合</param>
        /// <returns></returns>
        [Service(Date = "2019-06-12", Director = "李龙", Name = "查询可用于和供应商进行签约的大社和分社（具有独立签约供应商资质的）的集合")]
        Task<PageDataList<OrganizationDto>> GetOrgListForSign(SignOrgQueryDto queryInfo);

        /// <summary>
        /// 查询我自己所在的机构的全部机构列表
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-06-17", Director = "李龙", Name = "查询我自己所在的机构的全部机构列表")]
        Task<ResultDto<List<OrgSimpleDto>>> GetMyTeamOrgList(int orgId);

        /// <summary>
        /// 设置门店审批状态 
        /// </summary>
        /// <param name="stateSetDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-07-16", Director = "wyq", Name = "设置门店审批状态 ")]
        Task<bool> SetAuditState(OrgStateSetDto stateSetDto);

        /// <summary>
        /// 查询门店/直属门店/直属部门的信息以及与其结算的上级机构信息
        /// </summary>
        /// <param name="storeOrgId">门店/直属门店/直属部门的机构ID</param>
        /// <returns></returns>
        [Service(Date = "2019-07-18", Director = "李龙", Name = "查询门店/直属门店/直属部门的信息以及与其结算的上级机构信息")]
        Task<ResultDto<OrgSettlementInfoDto>> GetSettlementOrgInfo(int storeOrgId);

        /// <summary>
        /// 查询门店/直属门店/直属部门的上级可开票的机构信息
        /// </summary>
        /// <param name="storeOrgId">门店/直属门店/直属部门的机构ID</param>
        /// <returns></returns>
        [Service(Date = "2019-07-29", Director = "李龙", Name = "查询门店/直属门店/直属部门的开票机构")]
        Task<ResultDto<OrgSettlementInfoDto>> GetBillingOrgInfo(int storeOrgId);

        /// <summary>
        /// 查询指定层级、省、市、区的下属机构集合(带分页)
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        [Service(Date = "2019-07-23", Director = "李龙", Name = "查询指定层级、省、市、区的下属机构集合(带分页)")]
        Task<PageDataList<OrganizationDto>> GetChildrenOrgList(OrganizationQueryDto queryInfo);

        /// <summary>
        /// 发票管理使用
        /// </summary>
        /// <param name="queryDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-07-24", Director = "YP", Name = "发票管理使用")]
        Task<PageDataList<OrganizationDto>> GetNotInIdsOrgInfo(InvoiceOrgQueryDto queryDto);

        /// <summary>
        /// 根据IdList查询机构列表
        /// </summary>
        /// <param name="idList"></param>
        /// <returns></returns>
        [Service(Date = "2019-07-24", Director = "YP", Name = "根据IdList查询机构列表")]
        Task<List<OrgSimpleDto>> GetListByIdList(List<int> idList);

        /// <summary>
        /// 查询用户所属的机构列表
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        [Service(Date = "2019-08-16", Director = "TTTan", Name = "查询用户所属的机构列表")]
        Task<List<OrgDto>> GetBriefListByUserId(Guid userId);

        /// <summary>
        /// 获取大社/分社下所有门店(过滤掉有独立签约资质分社下的门店)
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        [Service(Date = "2019-08-20", Director = "wyq", Name = "获取大社/分社下所有门店(过滤掉有独立签约资质分社下的门店)")]
        Task<PageDataList<OrgSimpleDto>> GetSubStoreList(OrganizationQueryDto queryInfo);
        /// <summary>
        /// 根据指定的orgid和level查询他的下级单位
        /// </summary>
        /// <param name="orgId"></param>
        /// <param name="orgLevel"></param>
        /// <returns></returns>
        [Service(Date = "2019-09-05", Director = "zg", Name = "根据指定的orgid和level查询他的下级单位 ")]
        Task<List<OrganizationEntity>> GetMySubOrgList(int orgId, int orgLevel);


        /// <summary>
        /// /获取小程序订单设置归属门店列表
        /// </summary>
        /// <param name="levelpath"></param>
        /// <returns></returns>
        Task<List<OrganizationEntity>> GetWXSetupOrgList(string levelpath);
        Task<PageDataList<OrganizationCashViewDto>> GetMyCashpoolSubOrgPageList(OrganizationQueryDto queryInfo);
        /// <summary>
        /// 查询大社下有独立结算资质的分社列表 
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        Task<ResultDto<List<OrganizationEntity>>> GetSettlementBySelfBrancheList(int orgId);

        /// <summary>
        /// 修改小程序企业介绍
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        Task<ResultDto<int>> UpdateOrgMPOrgProfile(OrgMPOrgProfileSaveDto input);


        /// <summary>
        /// 查询组织机构集合
        /// </summary>
        /// <param name="queryInfo"></param>
        /// <returns></returns>
        [Service(Date = "2019-10-22", Director = "焦石", Name = "查询组织机构集合 ")]
        Task<List<OrganizationEntity>> GetOrganizationEntities(OrganizationSQueryDto queryInfo);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-10-22", Director = "焦石", Name = "查询组织机构集合 ")]
        Task<List<OrgSimpleDto>> GetMySubOrgAll(int orgId);

        /// <summary>
        /// 根据大社Id获取大社下的全部独立分社
        /// </summary>
        /// <param name="orgId"></param>
        /// <returns></returns>
        [Service(Date = "2019-11-15", Director = "YP", Name = "根据大社Id获取大社下的全部独立分社")]
        Task<List<int>> GetIsAllowContractSupplierBranch(int orgId);

        /// <summary>
        /// TAS我的供应商区域设置获取组织机构信息分页列表
        /// </summary>
        /// <param name="queryDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-11-15", Director = "YP", Name = "TAS我的供应商区域设置获取组织机构信息分页列表")]
        Task<PageDataList<OrganizationDto>> GetMySupplierOrgQueryInfo(MySupplierOrgQueryDto queryDto);

        /// <summary>
        /// 签约大社/分社下未直接签约的分社和门店
        /// </summary>
        ///  <param name="allSignedOrg">全部已经签约的大社/分社</param>
        /// <param name="signedOrg">过滤条件下已经签约的大社/分社</param>
        /// <param name="allSettings">根据供应商Id获取针对供应商全部分销区域设置</param>
        /// <param name="queryDto"></param>
        /// <returns></returns>
        [Service(Date = "2019-11-15", Director = "gl", Name = "签约大社/分社下未直接签约的分社和门店")]
        Task<PageDataList<OrganizationDto>> GetInheritSignOrgPageData(List<OrgSimpleDto> allSignedOrg, List<OrgSimpleDto> signedOrg, List<OrgSupplierReleaseSettingsView> allSettings, OrganizationQueryDto queryDto);
        /// <summary>
        /// 获取指定组织机构下所有子集
        /// </summary>
        /// <param name="orgIds"></param>
        /// <returns></returns>
        [Service(Date = "2019-11-26", Director = "YP", Name = "签约大社/分社下未直接签约的分社和门店")]
        Task<List<SignProductOrg>> GetOrgSimpleByIds(List<string> orgIds);

        /// <summary>
        /// 根据Id集合获取组织机构信息
        /// </summary>
        /// <param name="orgIds"></param>
        /// <returns></returns>
        [Service(Date = "2019-12-4", Director = "YP", Name = "根据Id集合获取组织机构信息")]
        Task<List<OrganizationEntity>> GetOrganizationEntityByOrgIdList(List<int> orgIds);
    }
}
